<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>~/itimer/src/buttonHandler.vhd.html</title>
<meta name="Generator" content="Vim/7.2">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#00008b">-- Company&nbsp;&nbsp;&nbsp;&nbsp; : EIA / HTA </font><br>
<font color="#00008b">-- Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: Yves Peissard &lt;ypeissard@gmail.com&gt;</font><br>
<font color="#00008b">-- </font><br>
<font color="#00008b">-- Creation Date : 23/04/2009</font><br>
<font color="#00008b">-- File&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: buttonHandler.vhdl</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">-- Abstract : This is the buttonHandler of the iTimer project.</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It checks if the buttonInput was pressed longer than a</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;given time maxTime.</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If buttonInput was pressed longer than maxTime, we send </font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a logical 1 to the longPush output.</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If buttonInput was not pressed longer than maxTime, we </font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;send a logical 1 to the simplePush output.</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inputs:</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buttonInput : std_logic, input received from the mainbutton</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clockInput&nbsp;&nbsp;: std_logic, clock signal</font><br>
<font color="#00008b">--&nbsp;&nbsp;</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Outputs:</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simplePush&nbsp;&nbsp;: std_logic, 1 if mainbutton not pressed</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; longer than maxTime</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longPush&nbsp;&nbsp;&nbsp;&nbsp;: std_logic, 1 if mainbutton pressed </font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; longer than maxTime</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<br>
<font color="#a52a2a"><b>library</b></font>&nbsp;IEEE<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;IEEE<font color="#6a5acd">.</font>STD_LOGIC_1164<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;IEEE<font color="#6a5acd">.</font>STD_LOGIC_ARITH<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;IEEE<font color="#6a5acd">.</font>STD_LOGIC_UNSIGNED<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<br>
<br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>entity</b></font>&nbsp;buttonHandler <font color="#a52a2a"><b>is</b></font>&nbsp;<br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>port</b></font>&nbsp;<font color="#6a5acd">(</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;buttonInput <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>in</b></font>&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font>&nbsp;<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;clockInput <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>in</b></font>&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#6a5acd">;</font>&nbsp;<br>
&nbsp;&nbsp; simplePush <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>out</b></font>&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;longPush <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>out</b></font>&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">);</font><br>
<font color="#a52a2a"><b>end</b></font>&nbsp;buttonHandler<font color="#6a5acd">;</font><br>
<br>
<br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>architecture</b></font>&nbsp;buttonHandler_arch <font color="#a52a2a"><b>of</b></font>&nbsp;buttonHandler <font color="#a52a2a"><b>is</b></font><br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- internal signals</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- FIXME: at the final implementation we need to have a larger </font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busWaitedTime because 9 downto 0 </font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is not enought for 1.5 sec</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;busWaitedTime<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic_vector</b></font>&nbsp;<font color="#6a5acd">(</font><font color="#ff00ff">11</font>&nbsp;<font color="#a52a2a"><b>downto</b></font>&nbsp;<font color="#ff00ff">0</font><font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">&quot;000000000000&quot;</font>&nbsp;<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;reStartTime&nbsp;&nbsp;<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font>&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;simplePush_intern <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;longPush_intern <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- TODO: set maxTime to the 1500ms specified</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- in our architecture documentation</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- but for testing the code we had to set it</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- to a small value that we don't have</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- to wait too long each time we compile&nbsp;&nbsp;&nbsp;&nbsp;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;maxTime <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>integer</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">1500</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;isLongPushed <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;old_isLongPushed <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>signal</b></font>&nbsp;old_buttonInput<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
<br>
<font color="#a52a2a"><b>begin</b></font>&nbsp;<font color="#00008b">--architecture</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- instantiate waitedTime:</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;i_waitedTime<font color="#2e8b57"><b>:</b></font><font color="#a52a2a"><b>entity</b></font>&nbsp;work<font color="#6a5acd">.</font>waitedTime<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>port</b></font>&nbsp;<font color="#a52a2a"><b>map</b></font>&nbsp;<font color="#6a5acd">(</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clockInput&nbsp;&nbsp;&nbsp;&nbsp;<font color="#2e8b57"><b>=&gt;</b></font>&nbsp;clockInput<font color="#6a5acd">,</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reStartTime&nbsp;&nbsp; <font color="#2e8b57"><b>=&gt;</b></font>&nbsp;reStartTime<font color="#6a5acd">,</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busWaitedTime <font color="#2e8b57"><b>=&gt;</b></font>&nbsp;busWaitedTime<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#6a5acd">);</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;main_process <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font>&nbsp;<font color="#6a5acd">(</font>clockInput<font color="#6a5acd">,</font>buttonInput<font color="#6a5acd">)</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>begin</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- just do something if he have a rising clock event</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>clockInput<font color="#2e8b57"><b>'event</b></font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;clockInput <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- be sure that we only have reStartTime</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- at 1 during one clock cycle</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>reStartTime <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reStartTime <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- if we detect a rising edge of buttonInput</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- we set reStartTime at 1</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- we need to set isLongPushed to 1 here,</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- so we can make sure that we only send one</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- longPush while the user keeps pressing the</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- button for 10 seconds for example</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>buttonInput <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;old_buttonInput <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reStartTime <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>old_isLongPushed <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isLongPushed <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- else if we have a falling edge of buttonInput</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>elsif</b></font>&nbsp;<font color="#6a5acd">(</font>old_buttonInput <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;buttonInput <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reStartTime <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- if busWaitedTime is smaller than maxTime</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- we set simplePush at 1 and we set reStartTime at 1</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>conv_integer<font color="#6a5acd">(</font>busWaitedTime<font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>&lt;</b></font>&nbsp;maxTime<font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simplePush_intern <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simplePush <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>old_isLongPushed <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isLongPushed <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- make sure that we only have longPush</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- at 1 during one clock cycle</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- make sure that we only have simplePush</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- at 1 during one clock cycle</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>simplePush_intern <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simplePush_intern <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simplePush <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- make sure that we only have longPush</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- at 1 during one clock cycle</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>longPush_intern <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longPush_intern <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longPush <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- if busWaitedTime is greater than maxTime and isLongPushed is at 0</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>conv_integer<font color="#6a5acd">(</font>busWaitedTime<font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>&gt;</b></font>&nbsp;maxTime <font color="#2e8b57"><b>and</b></font>&nbsp;old_isLongPushed <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longPush_intern <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isLongPushed <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longPush <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- update old_buttonInput, that we can check</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- for it at the next clock cycle</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;old_isLongPushed <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;isLongPushed<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;old_buttonInput <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;buttonInput<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font>&nbsp;main_process<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
<font color="#a52a2a"><b>end</b></font>&nbsp;buttonHandler_arch<font color="#6a5acd">;</font><br>
</font></body>
</html>
